package cn.tianjindong.blog_portal.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tianjindong.blog.mapper.BlogArticleCommentMapper;
import cn.tianjindong.blog.pojo.BlogArticleComment;
import cn.tianjindong.blog.pojo.BlogArticleCommentExample;
import cn.tianjindong.blog.pojo.BlogArticleCommentExample.Criteria;
import cn.tianjindong.blog_portal.service.CommentService;

@Service
public class CommentServiceImpl implements CommentService {

	@Autowired
	private BlogArticleCommentMapper commentMapper;
	
	@Override
	public boolean addComment(Long userId, Long articleId, BlogArticleComment comment) {
		comment.setCreatetime(new Date());
		comment.setUserId(userId);
		comment.setArticleId(articleId);
		try {
			commentMapper.insertSelective(comment);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public List<BlogArticleComment> getCommentListByArticleId(Long articleId) {
		List<BlogArticleComment> list = commentMapper.getCommentListByArticleId(articleId);
		return list;
	}

}
